package server_data_init

import (
	"go_server/game_server/dao/server_dao"
	"go_server/zinx/zconf"
	"sync"
)

var(
	ServerData *serviceDataInit
)

type serviceDataInit struct {
	ServerInf *server_dao.ServerInfo
	RoleIDLock sync.Mutex
}

func (s *serviceDataInit)InitServerInfo() {
	serverInfo := server_dao.GetServerInfoById(zconf.GlobalObject.Id)
	if serverInfo == nil {
		serverInfo = server_dao.NewServerInfoData()
	}

	s.ServerInf = serverInfo
}

func (s *serviceDataInit)SaveServerInfo() {
	server_dao.UpdateServerInfo(zconf.GlobalObject.Id, &map[string]any{"role_sequence": s.ServerInf.RoleSequence})
}

func init() {
	ServerData = new(serviceDataInit)
}